# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=mlt
pkgver=7.28.0
pkgrel=0
pkgdesc="MLT Multimedia Framework"
url="https://www.mltframework.org/"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-3.0-or-later"
makedepends="
	cmake
	ffmpeg-dev
	fftw-dev
	frei0r-plugins-dev
	gtk+2.0-dev
	jack-dev
	ladspa-dev
	libarchive-dev
	libexif-dev
	libsamplerate-dev
	libvorbis-dev
	libxml2-dev
	python3-dev
	qt5-qtbase-dev
	qt5-qtsvg-dev
	qt6-qt5compat-dev
	qt6-qtbase-dev
	qt6-qtsvg-dev
	samurai
	sdl2-dev
	sox-dev
	swig
	vidstab-dev
	"
subpackages="$pkgname-dev $pkgname-doc py3-$pkgname:py3"
source="https://github.com/mltframework/mlt/releases/download/v$pkgver/mlt-$pkgver.tar.gz
	musl.patch
	"

case $CARCH in
ppc64le|s390x|riscv64|loongarch64)
	_opencv=OFF
	;;
*)
	makedepends="$makedepends opencv-dev"
	_opencv=ON
	;;
esac

case $CARCH in
	# undefined reference to `Mlt::Properties::set(char const*, long long)'
	x86|arm*) options="$options !check" ;;
esac

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DBUILD_TESTING="$(want_check && echo YES || echo NO)" \
		-DMOD_OPENCV=$_opencv \
		-DMOD_MOVIT=OFF \
		-DMOD_PLUS=OFF \
		-DMOD_RTAUDIO=OFF \
		-DMOD_RUBBERBAND=OFF \
		-DMOD_QT6=ON \
		-DMOD_GLAXNIMATE=ON \
		-DSWIG_PYTHON=ON \
		-DKwalify_EXECUTABLE=/bin/true
	cmake --build build
}

check() (
	cd build
	. ../setenv
	ctest --output-on-failure -E 'QtTest:properties'
)

package() {
	cd build

	DESTDIR="$pkgdir" cmake --install .
}

py3() {
	pkgdesc="$pkgdesc (Python bindings)"

	amove usr/lib/python*
}

sha512sums="
a252da56b668968e56a7b0e81283b0b8e0ec8cd28502e3ab6e0aff67e22620ba61bf4feb88134e0d483884e31f2d18efe2d60b6badf0b6ffae4ad26ee646baf9  mlt-7.28.0.tar.gz
18e8d87b8eda186c60002c31993aa615bebefe40037c76891812f6ff3201b0b8704d928da9f84d3bbda231149d1827448eebf81c5a7081d1afd05505547e479d  musl.patch
"
